#ifndef TCPBASE_H
#define TCPBASE_H

#include <QObject>
#include <QTcpSocket>
#include "commonmessage.h"

class TcpBase : public QObject
{
    Q_OBJECT
public:
    explicit TcpBase(QObject *parent = nullptr);
    virtual bool closeConnetion();
    virtual bool isOpen();
    virtual void sendMsg(QString msg);

protected:
    QTcpSocket *socket;
    MesSource source;

protected slots:
    virtual void onRecvMsg();
    virtual void socketErrorHandler(QAbstractSocket::SocketError);

signals:
    void connectSuccess(QString ip, qint16 port);
    void recvNewMsg(QString msg);
    void sendMsgToMain(MesSource, CommonMessage);
};

#endif // TCPBASE_H
